<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/12/16
 * Time: 16:22
 */

/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/12/16
 * Time: 14:19
 */

include_once '../tools/DbTools.php';
session_start();

include_once '../common/common.php';
$isLogin = getLoginStatus();
if(!$isLogin){
    echo '尚未登入，<a href="../user/loginUi.php">请先登入</a>';die;
}
$money = $_POST['money'];
if(empty($money) || $money<0){
    echo '存款金额有误，<a href="moneyIn.php">重新存款</a>';die;
}
$token = $_COOKIE['Token'];
$userInfo = $_SESSION[$token];

//调用函数

DbTools::init();
$result = changeMoney(1,$userInfo['CardId'],$money);
if($result['status']){
    echo '存款成功<a href="moneyIn.php">继续存款</a>';
}else{
    echo '存款有误： '.$result['message'];
}
DbTools::close();